<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:icecore="http://www.icefaces.org/icefaces/core"
      xmlns:ace="http://www.icefaces.org/icefaces/components"
      xmlns:ice="http://www.icesoft.com/icefaces/component">

<h:head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
   <title>Tribble Score Card Application</title>
   <link rel="stylesheet" type="text/css" href="../StyleWeb/trek_css/style.css" />
   <link rel="stylesheet" type="text/css" href="../StyleWeb/xmlhttp/css/rime/rime.css" />
   <link href="./images/tribble2.ico" rel="shortcut icon" type="image/x-icon"></link>
   <link href="./images/tribble2.ico" rel="icon" type="image/x-icon"></link>
</h:head>

<h:body>
   <!-- In order to use this you have to have a reference in the faces-config.xml file... -->
   <ice:loadBundle var="msgs" basename="resources.messages" />

   <h:form id="form">

<ice:panelGroup style="width:350px;">
   <ice:panelGrid columns="1" cellpadding="1px" rowClasses="row1, row2, row3" style="width: 100%; display: block; margin: auto; text-align: center;">
   <ice:panelGrid columns="4">
      <ice:commandButton value="POISON" actionListener="#{formBean.scorePoison}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="TOXIN" actionListener="#{formBean.scoreToxin}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="ANTIDOTE" actionListener="#{formBean.scoreAntidote}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="SCORE" actionListener="#{formBean.scoreScore}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
   </ice:panelGrid>
   <ice:panelGrid columns="4">
      <ice:commandButton value="TALLY" actionListener="#{formBean.scoreTally}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="COPY" actionListener="#{formBean.scoreCopy}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="BONUS" actionListener="#{formBean.scoreBonus}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="QUADRUPLE" actionListener="#{formBean.scoreQuadruple}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
   </ice:panelGrid>
   <ice:panelGrid columns="3">
      <ice:commandButton value="TALLY" actionListener="#{formBean.scoreTally}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="WINNER" actionListener="#{formBean.scoreWinner}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Score points" />
      <ice:commandButton value="CLEAR" actionListener="#{formBean.clearScore}"
                         partialSubmit="true" styleClass="tribbleScoreBtn"
                         title="Clear points" />
   </ice:panelGrid>
</ice:panelGrid>
</ice:panelGroup>
<p/>
<p/>

<!--
<ice:panelPopup id="scorePadd" draggable="false"
                modal="true" visible="#{formBean.scorePaddPopupRendered}"
                autoCentre="true" styleClass="corePopup">
      <f:facet name="header">
         <ice:panelGroup styleClass="popupHeaderWrapper">
            <ice:outputText value="Enter the amount of tribbles scored..." styleClass="popupHeaderText"/>
            <ice:commandButton type="button" image="images/popupclose.gif"
                               actionListener="#{formBean.toggleScorePaddPopup}"
                               styleClass="popupHeaderImage"
                               title="Close Popup" alt="Close" />
         </ice:panelGroup>
      </f:facet>
</ice:panelPopup>
-->

<ice:panelGroup styleClass="panelPopupContainer">
   <ice:panelGrid columns="6" cellspacing="2px">

      <ice:inputText id="hundredThousandsAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of hundred thousand tribbles scored...."
                     tabindex="1"
                     value="#{formBean.hundredThousands}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:inputText id="tenThousandsAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of ten thousand tribbles scored...."
                     tabindex="2"
                     value="#{formBean.tenThousands}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:inputText id="thousandsAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of thousand tribbles scored...."
                     tabindex="3"
                     value="#{formBean.thousands}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:inputText id="hundredsAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of hundred tribbles scored...."
                     tabindex="4"
                     value="#{formBean.hundreds}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:inputText id="tensAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of ten tribbles scored...."
                     tabindex="5"
                     value="#{formBean.tens}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:inputText id="onesAmount" partialSubmit="true"
                     styleClass="tribbleScoreTxt"
                     title="Enter number of one tribbles scored...."
                     tabindex="6"
                     value="#{formBean.ones}">
         <f:validateLongRange minimum="0" />
      </ice:inputText>

      <ice:outputLabel value="100k's" styleClass="tribbleScoreLbl"/>
      <ice:outputLabel value="10k's" styleClass="tribbleScoreLbl"/>
      <ice:outputLabel value="1k's" styleClass="tribbleScoreLbl"/>
      <ice:outputLabel value="100's" styleClass="tribbleScoreLbl"/>
      <ice:outputLabel value="10's" styleClass="tribbleScoreLbl"/>
      <ice:outputLabel value="1's" styleClass="tribbleScoreLbl"/>
</ice:panelGrid>
</ice:panelGroup>

<ice:messages />

<!--  START : DATATABLE CODE --> 
   <ice:dataTable id="playerTable" value="#{formBean.players}" var="player" rows="6">
     <!--  COLUMN : SELECTED --> 
     <ice:column style="text-align:center;">
        <f:facet name="header"> <ice:outputText value="Scored"/> </f:facet>
        <ice:selectBooleanCheckbox value="#{player.selected}"/>
     </ice:column>

     <!--  COLUMN : Name --> 
     <ice:column>
        <f:facet name="header"> <ice:outputText value="Name"/> </f:facet>
        <ice:outputText value="#{player.name}" style="font-family: Courier;"/>
     </ice:column>

     <!--  COLUMN : Round 1 Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Round 1"/> </f:facet>
        <ice:panelGroup panelTooltip="r1ToolTip">
           <ice:outputText value="#{player.roundOne.totalScore}"/>
        </ice:panelGroup>
        <ice:panelTooltip id="r1ToolTip">
           <f:facet name="body"> <ice:outputText value="#{player.roundOne.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
        </ice:panelTooltip>
     </ice:column>

     <!--  COLUMN : Round 2 Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Round 2"/> </f:facet>
        <ice:panelGroup panelTooltip="r2ToolTip">
           <ice:outputText value="#{player.roundTwo.totalScore}" />
        </ice:panelGroup>
        <ice:panelTooltip id="r2ToolTip">
           <f:facet name="body"> <ice:outputText value="#{player.roundTwo.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
        </ice:panelTooltip>
     </ice:column>

     <!--  COLUMN : Round 3 Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Round 3"/> </f:facet>
        <ice:panelGroup panelTooltip="r3ToolTip">
           <ice:outputText value="#{player.roundThree.totalScore}" />
        </ice:panelGroup>
        <ice:panelTooltip id="r3ToolTip">
           <f:facet name="body"> <ice:outputText value="#{player.roundThree.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
        </ice:panelTooltip>
     </ice:column>

     <!--  COLUMN : Round 4 Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Round 4"/> </f:facet>
        <ice:panelGroup panelTooltip="r4ToolTip">
           <ice:outputText value="#{player.roundFour.totalScore}" />
        </ice:panelGroup>
        <ice:panelTooltip id="r4ToolTip">
           <f:facet name="body"> <ice:outputText value="#{player.roundFour.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
        </ice:panelTooltip>
     </ice:column>

     <!--  COLUMN : Round 5 Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Round 5"/> </f:facet>
        <ice:panelGroup panelTooltip="r5ToolTip">
           <ice:outputText value="#{player.roundFive.totalScore}" />
        </ice:panelGroup>
        <ice:panelTooltip id="r5ToolTip">
           <f:facet name="body"> <ice:outputText value="#{player.roundFive.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
        </ice:panelTooltip>
     </ice:column>
     
     <!--  COLUMN : Total Score--> 
     <ice:column style="text-align:right;">
        <f:facet name="header"> <ice:outputText value="Total"/> </f:facet>
        <ice:outputText value="#{player.totalScore}" />
     </ice:column>
   </ice:dataTable>

<!--  END   : DATATABLE CODE --> 

<!--  
      <ice:commandButton value="Press to add Tribble Players" actionListener="#{formBean.toggleAddNamesPopup}"
                         immediate="true" partialSubmit="true" style="float: right; margin-top: 2px; margin-right: 2px;"
                         title="Add Tribble Players" />
-->
<ice:panelGroup styleClass="panelPopupContainer">
   <ice:panelPopup id="enterNamesPopup" draggable="false"
                   modal="true" visible="#{formBean.addNamesPopupRendered}"
                   autoCentre="true" styleClass="corePopup">
      <f:facet name="header">
         <ice:panelGroup styleClass="popupHeaderWrapper">
            <ice:outputText value="Enter Participating Tribble Players..." styleClass="popupHeaderText"/>
            <ice:commandButton type="button" image="images/popupclose.gif"
                               actionListener="#{formBean.toggleAddNamesPopup}"
                               styleClass="popupHeaderImage"
                               title="Close Popup" alt="Close" />
         </ice:panelGroup>
      </f:facet>

      <f:facet name="body">
         <ice:panelGroup styleClass="popupBody"> <center>
            <ice:panelGrid id="dataEntry" columns="2">
               <ice:outputText value="Please Enter Player's Name:" />
               <ice:inputText id="playerName" partialSubmit="true"
                              validator="#{formBean.validatePlayerNameBeforeAdd}"
                              title="Enter name...." required="true"
                              value="#{formBean.name}">
                  <f:validateLength for="playerName" minimum="2" />
               </ice:inputText>


               <ice:commandButton id="addPlayerBtn"
                                  value="Add Tribble Player"
                                  actionListener="#{formBean.addPlayer}"
                                  style="float: right; margin-top: 2px; margin-right: 2px;"
                                  title="Add Tribble Player" />

               <ice:commandButton value="Done" immediate="true" type="submit"
                                  actionListener="#{formBean.toggleAddNamesPopup}"
                                  style="float: right; margin-top: 2px; margin-right: 2px;"
                                  title="Press to start scoring..." />

            </ice:panelGrid>
         </center>
         <ice:message for="playerName" style="color:red; width:150px; overflow:auto;"/>
          </ice:panelGroup>
      </f:facet>
   </ice:panelPopup>
</ice:panelGroup>
   </h:form>
</h:body>

<h:outputStylesheet library="org.icefaces.component.skins" name="rime.css" />
</html>